// ==UserScript==
 // @name            Wow Armory Flash cleanup
 // @namespace       tag:jerry:wow:armory
 // @description     Remove most flash elements from the armory
 // @include         http://armory.worldofwarcraft.com/*
 // @include         http://armory.wow-europe.com/*
// ==/UserScript==

(funtion() {

window.addEventListener("load", function () {
	var objects = document.evaluate("//object/embed", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

	GM_log("found " + objects.snapshotLength + " embed(s)");
	for (var i = 0; i < objects.snapshotLength; ++i) {
		var object = objects.snapshotItem(i);
		if(object.type == "application/x-shockwave-flash") {
			var src = object.src;
			GM_log("found : " + src);

			var parent = object.parentNode;
			parent.removeChild(object);
			if (src == "images/level.swf") {
				var level = null;
				var params = document.evaluate("param[@name='flashvars']", parent, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
				for (var j = 0; j < params.snapshotLength; ++j) {
					var param = params.snapshotItem(j);
					var re = new RegExec("charLevel=([0-9]+)")

					level = re.exec(param.value);
				}
				var div = parent.parentNode;

				div.innerHTML = "<span style='color:yellow;'>"+level+"</span>";
			}
		}
	}
}, false);

})()
